package com.oa.modules.approvalsec1.controller;

import java.util.Arrays;
import java.util.Map;

import com.oa.common.utils.AppUtils;
import com.oa.modules.approvalsec1.entity.UserSocialEntity;
import com.oa.modules.approvalsec1.service.UserSocialService;
import com.oa.modules.sys.controller.AbstractController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.oa.common.utils.PageUtils;
import com.oa.common.utils.R;


/**
 * @author jiangwei
 * @email 785297226@qq.com
 * @date 2021-11-09 13:36:38
 */
@RestController
@RequestMapping("usersocial")
@Api(tags = "用户社会类型")
public class UserSocialController extends AbstractController {
    @Autowired
    private UserSocialService userSocialService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "列表")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = userSocialService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @ApiOperation(value = "信息")
    public R info(@PathVariable("id") Integer id) {
        UserSocialEntity userSocial = userSocialService.getById(id);
        return R.ok().put("userSocial", userSocial);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation(value = "保存")
    public R save(@RequestBody UserSocialEntity userSocial) {
        userSocial.setId(AppUtils.getUUID());
        userSocialService.save(userSocial);
        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation(value = "修改")
    public R update(@RequestBody UserSocialEntity userSocial) {
        userSocialService.updateById(userSocial);
        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperation(value = "删除")
    public R delete(@RequestBody String[] ids) {
        userSocialService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
